<?php

/*
 * Database actions (DB access, validations, checking.)
 * 
 * PHP version 5
 * 
 * LICENSE: This open source file is subject for training of the PHP 
 * - jQuery, available at http://localhost/public/index.php
 * 
 * @author Mamoudou Camara <camara.mamoudou@gmail.com>
 * @copyright 2013 Training PHP and jQeury
 * @license http://localhost/public/index.php
 * 
 * 
 */

class DB_Connect
{
    
/**
 * 
 * stores a database object
 * 
 * @var object A database object
 * 
 */
    
protected $db;

/**
 * 
 * checkign for a DB object or creates one if it isn't exist
 * 
 * @param object  $db A database object
 * 
 */
protected function __construct($dbo=NULL)
 {
    if(is_object($dbo))
    {
        $this-> db=$dbo;
    }
    
    else 
    {
        //Constants are defined in /sys/config/cred-inc.php  
        $dsn = "mysql:host=" . DB_HOST . ";dbname=" . DB_NAME;
      
        try 
        {
          $this->db = new PDO($dsn, DB_USER, DB_PASS);
        } 
        catch (Exception $e) 
        {
          //If DB connection is failed so output error.
           die ($e->getMesage());
        }
     }    
  }

   /* public static function __construct($dbo) {
        
    }*/
}

?>
